package fr.cpe.j2ee.projet.ejb;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;

import fr.cpe.j2ee.projet.model.Employee;
import fr.cpe.j2ee.projet.model.Project;

/**
 * Session Bean implementation class ProjectSession
 */
@Stateless
@LocalBean
public class ProjectSession extends AbstractDAO<Project>
{	
    /**
     * Default constructor.
     */
    public ProjectSession()
    {
    	super(Project.class);
    }
    
    public Project create(String name, String description, int budget, Employee manager) throws IllegalArgumentException
    {    	
    	if(manager == null)
    	{
    		throw new IllegalArgumentException("Impossible de créer un nouveau projet : le chef de projet sp�cifi� n'existe pas !");
    	}
    	
    	Project project = new Project();
    	project.setProName(name);
    	project.setProDescription(description);
    	project.setProBudget(budget);
    	project.setEmployee(manager);
    	
    	this.insert(project);
    	return project;
    }
}
